<?php
include_only();

function video_player($video, $subtitle)
{
$video_player = "
<script type='text/javascript'>
var stopat = '';
var startat = '';
var currenttime = '';

function rectime(sec) {
	var hr = Math.floor(sec / 3600);
	var min = Math.floor((sec - (hr * 3600))/60);
	sec -= ((hr * 3600) + (min * 60));
	sec += ''; min += '';
	while (min.length < 2) {min = '0' + min;}
	while (sec.length < 2) {sec = '0' + sec;}
	hr = (hr)?':'+hr:'';
	while (hr.length < 2) {hr = '0' + hr;}
	
	if(sec.substr(1,1) == '.') {sec = '0' + sec;}
	if(sec.length > 6){sec = sec.substr(0,6)}

	return hr + ':' + min + ':' + sec;
}

</script>

<center>
<font style='font-style:Arial Unicode MS;size:2;'>
<div id='container'>Loading video player ...</div>
<script type='text/javascript'>
jwplayer('container').setup({
flashplayer: 'jwplayer/player.swf',
file: '".$video."',
height: 270,
width: 480,
controlbar: 'bottom',";

if($subtitle!='')
{
$video_player = $video_player . "
   plugins: {
     'captions-2': {
       back: false,
       file: 'include/view_subtitle.php?table_name=".$subtitle."'
     }}
	 
	 ";
}

$video_player = $video_player . "
});
</script>
<script type='text/javascript'>
 jwplayer('container').onTime(function() { 

 currenttime = jwplayer().getPosition();
 
 currenttime = rectime(currenttime);
 
 document.getElementById('epicurrent').innerHTML = currenttime;
  
 if (jwplayer().getPosition() >= stopat && stopat != '')
 {
 jwplayer().pause();
 stopat = '';
 }
 
 });
 
</script>
</font>
</center>
";

return $video_player;
}

?>

